home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / PASCAL / FPKPAS65.ZIP / SRCRTLDO.ZIP / SOURCE / RTL / DOS / FMOUSE.PP < prev    next >
Encoding:
Text File  |  1996-07-23  |  6.0 KB  |  300 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {              FMouse Unit version 1.0                  }
  4. {            Made for FPK Pascal compiler               }
  5. {                                                       }
  6. {         Copyright (c) 1996 Felix Gartsman             }
  7. {                                                       }
  8. {*******************************************************}
  9. { The mail address of Felix Gartsmann is:
  10.   felix@main.aquanet.co.il
  11.   Please send suggestions,bugs etc. to him.
  12. }
  13. Unit FMouse;
  14.  
  15. {version 1.0}
  16.  
  17. Interface
  18.  
  19. {Mouse support functions and procedures,with error checking if mouse
  20. isn't present then the routine ends,if you want to remove error checking
  21. erase the statement If Not Mouse Then Exit; from each routine}
  22.  
  23. {check if mouse is present and sets the mouse variable}
  24. Function Check_Mouse:Boolean;
  25. {shows mouse pointer,text+graphics screen support}
  26. Procedure Show_Mouse;
  27. {hides mouse pointer}
  28. Procedure Hide_Mouse;
  29. {reads mouse position in pixels,divide by 8 to get text position,and reads
  30. buttons state(1-left button,2=right button,7=middle button)}
  31. Procedure read_mouse (var x,y:Longint;var buttons:Longint);
  32. {sets mouse pointer in text mode}
  33. Procedure Mouse_Cur(X,Y:Longint);
  34. {sets the mouse shape in text mode}
  35. Procedure Mouse_Shape(BackColor,ForColor,Ascii:LongInt);
  36. {sets the mouse ascii in text mode}
  37. Procedure Mouse_Ascii(Ascii:LongInt);
  38. {returns which button was pressed after last call to function}
  39. Function mouse_press(var x,y:Longint;button:Longint):Longint;
  40. {returns which button was realeased after last call to function}
  41. Function mouse_release (var row,col:Longint;button : Longint):integer;
  42. {set's mouse y range}
  43. Procedure mouse_yrange (min,max:Longint);
  44. {set's mouse y range}
  45. Procedure mouse_xrange (min,max:Longint);
  46. {set mouse speed}
  47. Procedure Micky(Horizontal ,Vertical:Longint);
  48. {return if right button pressed}
  49. Function IsRPres:Boolean;
  50. {return if left button pressed}
  51. Function IsLPres:Boolean;
  52. {set rectangle on screen that mouse will disappear if will point on it}
  53. Procedure Unseen_Mouse(x1,y1,x2,y2:Longint);
  54. {set window for mouse}
  55. Procedure MWindow(x1,y1,x2,y2:Longint);
  56.  
  57. Var
  58. Mouse:Boolean;
  59.  
  60. Implementation
  61.  
  62. Function Check_Mouse:Boolean;
  63. begin
  64. asm
  65. movb $0,U_FMOUSE_MOUSE
  66. movw $0,%AX
  67. pushl %ebp
  68. int     $0x33
  69. popl %ebp
  70. cmpw $0xffff,%ax
  71. jz true
  72. jmp sof
  73. true:
  74. movw $1,U_FMOUSE_MOUSE
  75. sof:
  76. end;
  77. end;
  78.  
  79. procedure show_mouse;
  80. begin
  81. If (Not Mouse) Then Exit;
  82.      asm
  83.         movw $1,%ax
  84.         pushl %ebp
  85.         int   $0x33
  86.         popl %ebp
  87.      end;
  88. end;
  89.  
  90. procedure hide_mouse;
  91. begin
  92. If (Not Mouse) Then Exit;
  93.      asm
  94.         movw $2,%ax
  95.         pushl %ebp
  96.         int   $0x33
  97.  
  98.         popl %ebp
  99.      end;
  100. end;
  101.  
  102. procedure read_mouse (var x,y:Longint;var buttons:Longint);
  103. begin
  104. If Not Mouse Then Exit;
  105.      asm
  106.         movw $3,%ax
  107.         pushl %ebp
  108.         int   $0x33
  109.         popl %ebp
  110.         movl 8(%ebp),%eax
  111.         movw %cx,(%eax)
  112.         movl 12(%ebp),%eax
  113.         movw %dx,(%eax)
  114.         movl 16(%ebp),%eax
  115.         movw %bx,(%eax)
  116. end;
  117. end;
  118.  
  119. function mouse_press(var x,y:Longint;button:Longint):Longint;
  120. begin
  121. If Not Mouse Then Exit;
  122.      asm
  123.         movw $5,%ax
  124.         movw 16(%ebp),%bx
  125.         pushl %ebp
  126.         int   $0x33
  127.         popl %ebp
  128.         movl 8(%ebp),%ebx
  129.         movw %cx,(%ebx)
  130.         movl 12(%ebp),%ebx
  131.         movw %dx,(%ebx)
  132.      end;
  133. end;
  134.  
  135. function mouse_release (var row,col:Longint;button : Longint):integer;
  136. begin
  137. If Not Mouse Then Exit;
  138.      asm
  139.         movw $6,%ax
  140.         movw 16(%ebp),%bx
  141.         pushl %ebp
  142.         int   $0x33
  143.         popl %ebp
  144.         movl 8(%ebp),%ebx
  145.         movw %cx,(%ebx)
  146.         movl 12(%ebp),%ebx
  147.         movw %dx,(%ebx)
  148.      end;
  149. end;
  150.  
  151. procedure mouse_yrange (min,max:Longint);
  152. begin
  153. If Not Mouse Then Exit;
  154.  
  155.      asm
  156.         movw $8,%ax
  157.         movw 8(%ebp),%cx
  158.         movw 12(%ebp),%dx
  159.         pushl %ebp
  160.         int   $0x33
  161.         popl %ebp
  162.      end;
  163. end;
  164.  
  165. procedure mouse_xrange (min,max:Longint);
  166. begin
  167. If Not Mouse Then Exit;
  168.      asm
  169.         movw $7,%ax
  170.         movw 8(%ebp),%cx
  171.         movw 12(%ebp),%dx
  172.         pushl %ebp
  173.         int   $0x33
  174.         popl %ebp
  175.      end;
  176. end;
  177.  
  178. Procedure Mouse_Cur(X,Y:Longint);
  179. Begin
  180. If Not Mouse Then Exit;
  181. asm
  182. movw $4,%ax
  183. movw 8(%ebp),%cx
  184. movw 12(%ebp),%dx
  185. shlw $3,%cx
  186. shlw $3,%dx
  187. pushl %ebp
  188. int  $0x33
  189. popl %ebp
  190. End;
  191. End;
  192.  
  193. Procedure Mouse_Shape(BackColor,ForColor,Ascii:LongInt);
  194. Begin
  195. If Not Mouse Then Exit;
  196. asm
  197. movw $0,%bx
  198. movw $0xa,%ax
  199. {xorw %cx,%cx}
  200. movw $0x00ff,%cx
  201. movb 8(%ebp),%dh
  202. shlb $4,%dh
  203. addb 12(%ebp),%dh
  204. {movb 16(%ebp),%dl}
  205. xorb %dl,%dl
  206. pushl %ebp
  207. int  $0x33
  208. popl %ebp
  209. End;
  210. End;
  211.  
  212. Procedure Mouse_Ascii(Ascii:LongInt);
  213. Begin
  214. If Not Mouse Then Exit;
  215. asm
  216. movw $0,%bx
  217. movw $0xa,%ax
  218. movw $0xff00,%cx
  219. movb 8(%ebp),%dl
  220. xorb %dh,%dh
  221. pushl %ebp
  222. int  $0x33
  223. popl %ebp
  224. End;
  225. End;
  226.  
  227. Procedure Unseen_Mouse(x1,y1,x2,y2:Longint);
  228. Begin
  229. if Not Mouse Then Exit;
  230. asm
  231. movw $0x0010,%ax
  232. movw 8(%ebp),%cx
  233. movw 12(%ebp),%dx
  234. movw 16(%ebp),%si
  235. movw 20(%ebp),%di
  236. pushl %ebp
  237.  
  238. int     $0x33
  239. popl %ebp
  240. end;
  241. End;
  242.  
  243. Procedure Micky(Horizontal ,Vertical:Longint);
  244.   Begin
  245.     If Not Mouse Then Exit;
  246.     asm
  247.     movw $0x0f,%ax
  248.     movw 8(%ebp),%cx
  249.     movw 12(%ebp),%dx
  250.     pushl %ebp
  251.     int     $0x33
  252.     popl %ebp
  253.     end;
  254.   End;
  255.  
  256. Function IsRPres:Boolean;
  257. Var
  258. W:Longint;
  259. Begin
  260. if Not Mouse Then Exit;
  261. IsRPres:=False;
  262. asm
  263. movw $3,%ax
  264. pushl %ebp
  265. int  $0x33
  266. popl %ebp
  267. movw %bx,-4(%ebp)
  268. end;
  269. if (W and $02)=$02 Then IsRPres:=True;
  270. end;
  271.  
  272. Function IsLPres:Boolean;
  273. Var
  274. W:Longint;
  275. Begin
  276. if Not Mouse Then Exit;
  277. IsLPres:=False;
  278. asm
  279. movw $3,%ax
  280. pushl %ebp
  281. int   $0x33
  282. popl %ebp
  283. movw %bx,-4(%ebp)
  284. end;
  285. if (W and $01)=$01 Then IsLPres:=True;
  286. end;
  287.  
  288. Procedure MWindow(x1,y1,x2,y2:Longint);
  289. Begin
  290. if Not Mouse Then Exit;
  291. mouse_xrange(x1,x2);
  292. mouse_yrange(y1,y2);
  293. End;
  294.  
  295. Begin
  296. Check_Mouse;
  297. End.
  298.  
  299.  
  300.